<?php session_start();
require"../admin/conexao.jsp";


       $tabela = $_GET["tabela"];
       $cod    = ($_GET["cod"] ? $_GET["cod"] : '');

	  


function getSelect($cod = null, $tabela){


             $sql="select * from $tabela order by 2 asc";
             $linha=$_SESSION['ADOCnn']->Execute("$sql");
             
             if($linha->RecordCount() != 0 ){
                $result = "<select name='p$tabela'>
                <option value=''>Selecione</option>\n
                ";
             	while(!$linha->EOF){
                   $codigo = $linha->fields[0];
                   $nome =htmlentities(trim($linha->fields[1]));
                   if($codigo == $cod){
                        $result .= "<option value='$codigo' selected class='select'>$nome</option>\n";
                   }else{
                        $result .= "<option value='$codigo'>$nome</option>\n";
                   }
                $linha->MoveNext();
                }
                $result .= "</select>";
              }

              return print $result;
}


getSelect($cod,$tabela);

?>



